package b.h.z;

import javax.ws.rs.core.MediaType;

import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;

public class Main {

	private static final String BASE_URI = "http://localhost:8888/Restful";

	public static void main(String[] args) {
		
		ClientConfig config = new DefaultClientConfig();
		Client client = Client.create(config);
		WebResource resource = client.resource(BASE_URI);
		WebResource res1 = resource.path("jaxrs").path("/UserService/jsonuser/1");
		System.out.println(res1.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class).toString());
		System.out.println(res1.accept(MediaType.APPLICATION_JSON).get(String.class));
		
		WebResource res2 = resource.path("jaxrs").path("/UserService/xmluser/1");
		System.out.println(res2.accept(MediaType.APPLICATION_XML).get(ClientResponse.class).toString());
		System.out.println(res2.accept(MediaType.APPLICATION_XML).get(String.class));
		
		WebResource res3 = resource.path("jaxrs").path("/UserService/textuser/1");
		System.out.println(res3.accept(MediaType.TEXT_XML).get(ClientResponse.class).toString());
		System.out.println(res3.accept(MediaType.TEXT_XML).get(String.class));

	}
}
